import { resolve } from 'path'
import { defineConfig, externalizeDepsPlugin } from 'electron-vite'
import react from '@vitejs/plugin-react'

export default defineConfig({

  main: {
    define: {
      'process.env.FORCE_UTF8': 'true'
    },
    plugins: [externalizeDepsPlugin()],
    build: {
      rollupOptions: {
        input: {
          index: resolve('src/main/index.ts'),
          // 新增 worker 入口配置
          engineWorker: resolve('src/scriptEngine/engineWorker.ts'),
          logWorker: resolve('src/LogService/logWorker.ts')
        },
        output: {
          // 保持文件名不变，便于 fork 引用
          entryFileNames: '[name].js'
        }
      }
    }
  },
  preload: {
    plugins: [externalizeDepsPlugin()]
  },
  renderer: {
    resolve: {
      alias: {
        '@renderer': resolve('src/renderer/src')
      }
    },
    plugins: [react()]
  }
})
